require 'active_support/core_ext/class/attribute'
module EasyForm
  module MapType
    def self.extended(base)
      base.class_attribute :mappings
      base.mappings = {}
    end

    def map_type(*args)
      map_to = args.extract_options![:to]
      raise ArgumentError, "#{__FILE__}:#{__LINE__}, You need to give :to as option to map_type" unless map_to
      self.mappings.merge!(args.each_with_object({}){|type, map| map[type] = map_to})
    end
  end
end